#include<stdio.h>
#define N 8
int removeDuplicates(int nums[]){
    int left =0;
    int right;
    for(right = 1; right < N; right++) {
            if(nums[right] != nums[left]){
                nums[++left] = nums[right];
            }
    }
    //left+1为非重复元素的个数
    printf("%d \n",left+1);
   return ++left;
}

int main(){
    int nums[N] = {1,2,2,5,5,6,6,8};
    int k = removeDuplicates(nums);
    for(int i = 0; i < k; i++) {
        printf("%d ", nums[i]); 
    }
    return 0;
}